package com.example.administrator.basedemos.activity;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.example.administrator.basedemos.R;
import com.example.administrator.basedemos.adapter.ExchangeStartlItemAdapter;
import com.example.administrator.basedemos.utils.RecycleUtil;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 创建者     ZCL
 * 创建时间   2018/7/20 11:41
 * 描述	      ${TODO}
 * <p>
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */
public class OptionalAddCurrencyActivity extends BaseZcActivity implements BaseQuickAdapter.OnItemChildClickListener {
    @BindView(R.id.market_search_edt)
    EditText  mMarketSearchEdt;

    @BindView(R.id.recyclerview_mm)
    RecyclerView mRecyclerviewMm;

    @BindView(R.id.recyclerview_mw)
    RecyclerView mRecyclerviewMw;
    private ArrayList<String> mList;

    @Override
    protected int setLayoutId() {
        return R.layout.activity_market_search;
    }

    @Override
    protected void initData() {
        mToolbarLy.setVisibility(View.GONE);
        mRecyclerviewMw.setVisibility(View.GONE);
        mMarketSearchEdt.setHint( getString(R.string.搜索币种));
        mList = new ArrayList<>();
        mList.add("0");
        mList.add("1");
        RecycleUtil.setLayoutMangerVertical(mRecyclerviewMm,this);
        ExchangeStartlItemAdapter adapter = new ExchangeStartlItemAdapter(R.layout.item_optinal_star, mList);
        adapter.setOnItemChildClickListener(this);
        mRecyclerviewMm.setAdapter(adapter);
    }

    @OnClick({R.id.market_search_cancel,R.id.search_edt_close})
    public void OnClik(View v) {
        switch (v.getId()) {
            case R.id.market_search_cancel:
                finish();
                break;
            case R.id.search_edt_close:
                mMarketSearchEdt.setText("");
                break;
        }
    }

    @Override
    public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
        String s = mList.get(position);
        boolean b = "0".equals(s);
        ((ImageView)view).setImageResource(b ?R.mipmap.star:R.mipmap.unstar);
        s = b?"1":"0";
        mList.remove(position);
        mList.add(position,s);
    }

}
